<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="js/layui/css/layui.css"/>
		<script src="js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/layui/layui.js" type="text/javascript" charset="utf-8"></script>
		
	<script src="js/layer/layer.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/Global.js" type="text/javascript" charset="utf-8"></script>
		
	</head>
	<body>
		<div id="add-Stuent" style="" >
		     
				   
				       <div class="layui-form-item center" hidden="hidden">
				    <label class="layui-form-label" style="width: 100px"  ></label>
				    <div class="layui-input-block">
				     <input type="text" name="name" id="userid"  style="width: 240px" lay-verify="required" disabled="disabled" autocomplete="off" class="layui-input">
				    </div>
				   </div>
				   
		         <div class="layui-form-item center" >
		          <label class="layui-form-label" style="width: 100px" >用户账号</label>
		          <div class="layui-input-block">
		           <input type="text" name="name" id="username" style="width: 240px" lay-verify="required" disabled="disabled" autocomplete="off" class="layui-input">
		          </div>
		         </div>
		         <div class="layui-form-item">
		          <label class="layui-form-label" style="width: 100px">旧密码</label>
		          <div class="layui-input-block">
		           <input type="text" name="type" id="oldPassword" required style="width: 240px" lay-verify="required" placeholder="请输入用户密码" autocomplete="off" class="layui-input">
		          </div>
		         </div>
				    <div class="layui-form-item">
				  <label class="layui-form-label" style="width: 100px">新密码</label>
				  <div class="layui-input-block">
				   <input type="text" name="type" id="newPassword" required style="width: 240px" lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
				  </div>
				 </div>
				  <div class="layui-form-item">
				  <label class="layui-form-label" style="width: 100px">确认密码</label>
				  <div class="layui-input-block">
				   <input type="text" name="type" id="rePassword" required style="width: 240px" lay-verify="required" placeholder="请确认密码" autocomplete="off" class="layui-input">
				  </div>
				 </div>
				 
				 
		        <button class="layui-btn" style="margin-left:100px" id="updateUserPassword"> 提交</button>
		       
			   
			   
		       
		    
		
	</body>
	<script type="text/javascript">
		$(function(){
			 var newscript = document.createElement('script');
			newscript.setAttribute('type','text/javascript');
			newscript.setAttribute('src','js/Global.js');
			var head = document.getElementsByTagName('head')[0];
			head.appendChild(newscript);
			
			         
			 	var id=window.globalConfig.id;
			$.ajax({
				url:"http://127.0.0.1:8080/user/findByOne",
				type:"get",
				data:{"userid":id},
				success:function(msg){
					$("#username").val(msg.data.username);
					$("#userid").val(msg.data.userid);
				}
			})
			
			
			$("#updateUserPassword").click(function(){
				var userid=$("#userid").val();
				var oldPassword=$("#oldPassword").val();
				var newPassword=$("#newPassword").val();
				var rePassword=$("#rePassword").val();
				if(userid!=null&&oldPassword!=null&&newPassword!=null&&rePassword!=null
				&&userid!=""&&oldPassword!=""&&newPassword!=""&&rePassword!=""
				){
					if(oldPassword==newPassword){
						layer.msg("新旧密码一致",{time:1000, icon:5, shift:6},function(){
							
						});
						return ;
					}else if(newPassword != rePassword){
						layer.msg("密码不一致",{time:1000, icon:5, shift:6},function(){
							
						});
						return;
					}else{
							
						$.ajax({
							 url:"http://127.0.0.1:8080/user/updata",
							 data:{
								 "userid":userid,
								 "oldPassword":oldPassword,
								 "newPassword":newPassword
							 },
							 success:function(msg){
								 if(msg.status==true){
									 alert(msg.data)
								 }else{
									 alert(msg.reason)
								 }
							 }
						})
					}
					
				}else{
					/* layer.msg("请不要有空哟",{time:1000, icon:5, shift:6},function(){
						
					}); */
					alert("请不要有空哟");
					return ;
				}
			})
			
		})
		  
	
			
		
	</script>
</html>
